/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "balances_employees")
public class BalanceEmployee extends BaseObject implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long id;
    private Date dateBalance;
    private Double amountWon;
    private Double amountPaid;
    private Double balance;
   // private Employee employee;
    private CutProcess cutProcess;
    private ProcessDressmaker processDressmaker;
    private PaymentsCut paymentsCut;
    private PaymentsPant paymentsPant;
    private PeriodPaymentEmployee periodPaymentEmployee;
    private String observation;
    private Integer typeBalance; // 1 normal increment ; 2 increment discount ; 3 normal payment ; 4 fail payment

    public BalanceEmployee(){}

    public BalanceEmployee(Double balance){
        this.balance = balance;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_balance_employee", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Temporal(TemporalType.DATE)
    public Date getDateBalance() {
        return dateBalance;
    }

    public void setDateBalance(Date date) {
        this.dateBalance = date;
    }

    @Column(name = "observation", length = 255)
    public String getObservation() {
        return observation;
    }

    public void setObservation(String observation) {
        this.observation = observation;
    }

    @Column(name="type_balance")
    public Integer getTypeBalance() {
        return typeBalance;
    }

    public void setTypeBalance(Integer typeBalance) {
        this.typeBalance = typeBalance;
    }

    @Column(name = "amount_won")
    public Double getAmountWon() {
        return amountWon;
    }

    public void setAmountWon(Double amountWon) {
        this.amountWon = amountWon;
    }

    @Column(name = "amount_paid")
    public Double getAmountPaid() {
        return amountPaid;
    }

    public void setAmountPaid(Double amountPaid) {
        this.amountPaid = amountPaid;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    @JoinColumn(name = "id_cut_process", referencedColumnName = "id_cut_process")
    @OneToOne
    public CutProcess getCutProcess() {
        return cutProcess;
    }

    public void setCutProcess(CutProcess cutProcess) {
        this.cutProcess = cutProcess;
    }

    @JoinColumn(name = "id_process_dressmaker", referencedColumnName = "id_process_dressmaker")
    @OneToOne
    public ProcessDressmaker getProcessDressmaker() {
        return processDressmaker;
    }

    public void setProcessDressmaker(ProcessDressmaker processDressmaker) {
        this.processDressmaker = processDressmaker;
    }

    @JoinColumn(name = "id_payments_cut", referencedColumnName = "id_payments_cut")
    @OneToOne
    public PaymentsCut getPaymentsCut() {
        return paymentsCut;
    }

    public void setPaymentsCut(PaymentsCut paymentsCut) {
        this.paymentsCut = paymentsCut;
    }

    @JoinColumn(name = "id_payments_pant", referencedColumnName = "id_payments_pant")
    @OneToOne
    public PaymentsPant getPaymentsPant() {
        return paymentsPant;
    }

    public void setPaymentsPant(PaymentsPant paymentsPant) {
        this.paymentsPant = paymentsPant;
    }

    @JoinColumn(name = "id_period_payment_employee", nullable = false)
    @ManyToOne(fetch = FetchType.LAZY)
    public PeriodPaymentEmployee getPeriodPaymentEmployee() {
        return periodPaymentEmployee;
    }

    public void setPeriodPaymentEmployee(PeriodPaymentEmployee periodPaymentEmployee) {
        this.periodPaymentEmployee = periodPaymentEmployee;
    }
    
    @Override
    public String toString() {
        return "com.click.app.model.BalanceEmployee[id=" + id + "]";
    }

    @Override
    public boolean equals(Object o) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(o instanceof BalanceEmployee)) {
            return false;
        }
        BalanceEmployee other = (BalanceEmployee) o;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

}
